﻿using System;
using System.Web;
using System.Web.Routing;
using System.Web.Mvc;

namespace Blog.Framework.Attributes
{
    public class LayoutAttribute : ActionFilterAttribute
    {
        string mMasterName;

        public LayoutAttribute(string masterName)
        {
            mMasterName = masterName;
        }

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if(typeof(ViewResult).IsAssignableFrom(filterContext.Result.GetType()))
            {
                ViewResult result = (ViewResult)filterContext.Result;
                result.MasterName = mMasterName;
            }
            base.OnActionExecuted(filterContext);
        }
    }
}
